<extend name="Include:Layout"/>
<block name="title">投诉建议</block>
<block name="style">
<style>
.weui_cells {font-size:14px;}
</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_navbar">
			<div class="toolbar">
		        <div class="toolbar-inner">
		            <a href="javascript:history.go(-1);" class="picker-button close-popup">关闭</a>
		            <h1 class="title" id="banji_title">投诉建议</h1>
		        </div>
		    </div>
		</div>
		<div class="weui_tab_bd container" id="container">
			<div class="weui_cells" style="background:#fff;margin-top:20px;">
		        <div class="weui_cell">
		            <div class="weui_cell_hd"><label class="weui_label">家长手机</label></div>
		            <div class="weui_cell_bd weui_cell_primary">
		                <input class="weui_input" type="number" name="tel" value="{$_SESSION['_loginUser_home']['mobile']}" pattern="[0-9]*" placeholder="请输入验证码">
		            </div>
		        </div>
		        <div class="weui_cell">
				    <div class="weui_cell_hd"><label class="weui_label">校区</label></div>
				    <div class="weui_cell_bd weui_cell_primary">
				    	<input class="weui_input" id="xiaoqu" type="text" name="xiaoqu" value="" readonly>
				    </div>
				</div>
		        <div class="weui_cell weui_cell_select weui_select_after">
		            <div class="weui_cell_hd">
		                <label for="" class="weui_label">留言主题</label>
		            </div>
		            <div class="weui_cell_bd weui_cell_primary">
		                <select class="weui_select" name="type" id="type">
		                    <option value="1">投诉</option>
		                    <option value="2">建议</option>
		                </select>
		            </div>
		        </div>
		        
		        <div class="weui_cell">
			        <div class="weui_cell_bd weui_cell_primary">
			          	<textarea class="weui_textarea" id="content" placeholder="请输入投诉建议" rows="3"></textarea>
			          	<div class="weui_textarea_counter"><span>0</span>/200</div>
			        </div>
			    </div>
		    </div>
		    
		    <div class="weui_btn_area">
		    	<input type="hidden" name="uid" value="{$_SESSION['_loginUser_home']['uid']}"/>
		        <a class="weui_btn weui_btn_primary btn-submit">提 交</a>
		    </div>
		</div>
	</div>
<div id="xiaoqu_popup" class="weui-popup-container">
  <div class="weui-popup-modal" style="background:#fff;">
    <div class="toolbar">
          <div class="toolbar-inner">
            <a href="javascript:;" class="picker-button closebtn">关闭</a>
            <h1 class="title" id="xiaoqu_title">选择校区</h1>
          </div>
    </div>
    <div class="modal-content">
	    <div class="weui_panel weui_panel_access" style="margin-top:0;">
	      <div class="weui_panel_bd"> 
	        <div class="weui_cells weui_cells_radio" id="xiaoqu_data">
			 
			</div>
	      </div>
	    </div>
    </div>
  </div>
</div>
<script id="xiaoqu_data_html" type="text/html">
{{each list as value index}}
<div class="weui_cell weui_check_label xiaoqu_class" onclick="get_xiaoqu('{{value.title}}',{{value.id}})" for="xq{{index}}" data-title="{{value.title}}" data-id="{{value.id}}">
	<div class="weui_cell_bd weui_cell_primary">
		<p><span class="cell_xiaoqu">{{value.title}}</span> <br/><span class="cell_xiaoqu_desc">电话：{{value.tel}}</span><br/><span class="cell_xiaoqu_desc">地址：{{value.address}}</span></p>
	</div>
	<div class="weui_cell_ft">
		{{if did == value.id}}
		<input type="radio" class="weui_check" name="radio_xq" checked="checked"  id="xq{{index}}" >
		{{else}}
		<input type="radio" class="weui_check" name="radio_xq"  id="xq{{index}}" >
		{{/if}}
		<span class="weui_icon_checked"></span>
	</div>
</div>
{{/each}}
</script>
</block>

<block name="script">
<script>
$(".closebtn").click(function(){
	$.closePopup();
	
})

$("#xiaoqu").click(function(){
	$.showLoading();
	var did = $(this).attr("data-values");
	if(!did) did = 0;
	$.get('/api/ygcl/getxiaoqu_new',function(ret){
		if(ret.status){
			var data = {
				'did':did,
				'list':ret.data
			}
			var html = template("xiaoqu_data_html", data);
			$("#xiaoqu_data").html(html);
			$.hideLoading();
			$("#xiaoqu_popup").popup();
		}else{
			$.alert('无校区','');
		}
	})
})

function get_xiaoqu(title,id){
	$("#xiaoqu").val(title);
	$("#xiaoqu").attr("data-values",id);
	$("#total").val('');
	$.closePopup();
}

$(".btn-submit").click(function(){
	var tel = $.trim($("input[name=tel]").val());
	var type = $("#type").val();
	var content = $.trim($("#content").val());
	if(!tel){
		$.alert("请输入手机号码", "");
		return false;
	}
	var xiaoqu =$("#xiaoqu").val();
	if($.trim(xiaoqu) == ''){
		$.alert("请选择校区","");
		return false;
	}
	if(!content){
		$.alert("请输入内容", "");
		return false;
	}
	$.showLoading();
	var uid = $("input[name=uid]").val();
	var did = $("#xiaoqu").attr("data-values");
	$.post('/home/my/savesuggest',{uid:uid,did:did,tel:tel,type:type,content:content},function(data){
		if(data.status){
			$.hideLoading();
			$.toast(data.info, "text",function(){
				location.reload();
			});
		}
	})
})
</script>
</block>